package ticket.enums;

/**
 * 座位类型
 * Created by forvoyager@outlook.com on 2018-10-09 15:53.
 */
public enum SeatType {

  SW((int)Math.pow(2,10), "商务座"),
  YD((int)Math.pow(2,9), "一等座"),
  ED((int)Math.pow(2,8), "二等座"),
  GR((int)Math.pow(2,7), "高级软卧"),
  RW((int)Math.pow(2,6), "软卧"),
  DW((int)Math.pow(2,5), "动卧"),
  YW((int)Math.pow(2,4), "硬卧"),
  RZ((int)Math.pow(2,3), "软座"),
  YZ((int)Math.pow(2,2), "硬座"),
  WZ((int)Math.pow(2,1), "无座"),
  OTHER((int)Math.pow(2,0), "其他"),
  ;

  private int code;
  private String label;

  private SeatType(int code, String label){
    this.code = code;
    this.label = label;
  }

  public int getCode() {
    return code;
  }

  public String getLabel() {
    return label;
  }

  public static SeatType parse(int code){
    for(SeatType s : values()){
      if(s.getCode() == code){
        return s;
      }
    }

    return null;
  }
}
